<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$tabs=array(
	array('op'=>'main','title'=>'经销概况'),
);
set_html('tabs',$tabs);
$merchid=$_SESSION['merchid'];
if($_RQ['op']=='main'){
	if($_RQ['id']){
		$_SESSION['merchid']=$_RQ['id'];
	}
	$merchid=$_SESSION['merchid'];
	$return['params']=array('daytype'=>0,'time'=>'','qushi'=>0,'qushitype'=>0);
	set_html('title','商户后台');
	exi($return);
}
if($_RQ['op']=='getdata'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'tomid'=>0);
	//创建时间
	if($_RQ['tstart'] && $_RQ['tend']){
		$params['createtime between']=array($_RQ['tstart'],$_RQ['tend']);
	}else{
		$daytype=intval($_RQ['daytype']);
		if($daytype==0){
			$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
			$params['createtime >']=$daytime;
		}elseif($daytype==1){
			$yesdaytime = mktime(0,0,0,date('m'),date('d')-1,date('Y'));
			$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
			$params['createtime between']=array($yesdaytime,$daytime);
		}elseif($daytype==2){
			$day7time = mktime(0,0,0,date('m'),date('d')-7,date('Y'));
			$params['createtime >']=$day7time;
		}elseif($daytype==3){
			
		}
	}
	//print_r($params);exit;
	$params['type']=0;
	$params['code']='';
	$data['luxiang']=pdo_count('jy_goodserpfw_merchlog',$params);
	$params['type']=0;
	unset($params['code']);
	$params['code <>']='';
	$data['lucode']=pdo_count('jy_goodserpfw_merchlog',$params);
	$params['type']=2;
	unset($params['code <>']);
	$params['code']='';
	$data['fanxiang']=pdo_count('jy_goodserpfw_merchlog',$params);
	$params['type']=2;
	unset($params['code']);
	$params['code <>']='';
	$data['fangcode']=pdo_count('jy_goodserpfw_merchlog',$params);
	//销售
	$params['type']=1;
	$params['code']='';
	$data['salexiang']=pdo_count('jy_goodserpfw_merchlog',$params);
	$params['type']=1;
	unset($params['code']);
	$params['code <>']='';
	$data['salecode']=pdo_count('jy_goodserpfw_merchlog',$params);
	$params['type']=3;
	unset($params['code <>']);
	$params['code']='';
	$data['tuixiang']=pdo_count('jy_goodserpfw_merchlog',$params);
	$params['type']=3;
	unset($params['code']);
	$params['code <>']='';
	$data['tuicode']=pdo_count('jy_goodserpfw_merchlog',$params);
	$return['params']=$params;
	$return['data']=$data;
	exi($return);
}